package com.ctrip.ibu.permissions.security.service.impl;

import com.ctrip.ibu.permissions.security.entity.User;
import com.ctrip.ibu.permissions.security.repository.UserRepository;
import com.ctrip.ibu.permissions.security.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * description
 *
 * @author r.shi 2020/03/30 21:11
 */
@Service
@Slf4j
public class UserServiceImpl implements UserService {
    @Autowired
    UserRepository userRepository;

    @Override
    public List<User> list(User user) {
        Example<User> example = Example.of(user);
        return userRepository.findAll(example);
    }

    @Override
    public User create(User user) {
        return userRepository.save(user);
    }

    @Override
    public User update(User user) {
        return userRepository.save(user);
    }

    @Override
    public void delete(User user) {
        userRepository.delete(user);
    }
}
